473,480 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

http/1.1 decompress

Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent over
the port.
My problem is the following, when I write the array to a txt file most of
the content is encoded.
The only things that are readable are the http headers from which I can read
that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET 2.0)
and SharpZipLib.Gzip.GzipInputstream but neither of them want to decompress
my array.
In the beginning I received several errors about an incorrect magicnumber
and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
..Net didn't throw any exceptions but it didn't decompress (the output is now
an empty file because the bytesread of my decompress stream is 0) my data
either.

Does anyone knows how that Internet Explorer performs the decompression or
how I can perform the decompression myself?

Thx in advance

Frederik.
Aug 25 '06 #1
4 3382
You've run into a rather rare animal there, Frederik, although I suppose
that at some point it's likely to catch on popularly, to save bandwidth.

I found a good article on the subject, which also links to some libraries
you can use:

http://www.15seconds.com/issue/020314.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in message
news:O5**************@TK2MSFTNGP05.phx.gbl...
Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent
over the port.
My problem is the following, when I write the array to a txt file most of
the content is encoded.
The only things that are readable are the http headers from which I can
read that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET 2.0)
and SharpZipLib.Gzip.GzipInputstream but neither of them want to
decompress my array.
In the beginning I received several errors about an incorrect magicnumber
and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
.Net didn't throw any exceptions but it didn't decompress (the output is
now an empty file because the bytesread of my decompress stream is 0) my
data either.

Does anyone knows how that Internet Explorer performs the decompression or
how I can perform the decompression myself?

Thx in advance

Frederik.

Aug 25 '06 #2
Kevin,

I don't seem to be able to solve the decompress problem but I have another
possible solution for my problem.
Maybe you can help me with that.
I should be able to remove the content-encoding field from the header before
the request is send to the server =the server won't compress the message
and I can read the response.
So I think I should create a sort of proxy that checks outgoing messages for
the content-encoding field.

I should capture the messages before they're are being send to port 80,
adjust them and do a resend.

The only problem is that I'm not sure how I can create such a construction.

Do you have an idea how I can start?
Thx in advance

Frederik
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:Of**************@TK2MSFTNGP04.phx.gbl...
You've run into a rather rare animal there, Frederik, although I suppose
that at some point it's likely to catch on popularly, to save bandwidth.

I found a good article on the subject, which also links to some libraries
you can use:

http://www.15seconds.com/issue/020314.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in
message news:O5**************@TK2MSFTNGP05.phx.gbl...
>Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent
over the port.
My problem is the following, when I write the array to a txt file most of
the content is encoded.
The only things that are readable are the http headers from which I can
read that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET 2.0)
and SharpZipLib.Gzip.GzipInputstream but neither of them want to
decompress my array.
In the beginning I received several errors about an incorrect magicnumber
and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
.Net didn't throw any exceptions but it didn't decompress (the output is
now an empty file because the bytesread of my decompress stream is 0) my
data either.

Does anyone knows how that Internet Explorer performs the decompression
or how I can perform the decompression myself?

Thx in advance

Frederik.


Aug 26 '06 #3
Thus wrote Frederik,
Kevin,

I don't seem to be able to solve the decompress problem but I have
another
possible solution for my problem.
Maybe you can help me with that.
I should be able to remove the content-encoding field from the header
before
the request is send to the server =the server won't compress the
message
and I can read the response.
So I think I should create a sort of proxy that checks outgoing
messages for
the content-encoding field.
I should capture the messages before they're are being send to port
80, adjust them and do a resend.

The only problem is that I'm not sure how I can create such a
construction.

Do you have an idea how I can start?
To avoid receiving compressed content, make sure *not* to send an Accept-Encoding
header with a value of "gzip" or "deflate". .NET 1.x has no built-in support
for compression, so just make sure you don't set the header in your code
explicitly. In .NET 2.0, set HttpWebRequest.AutomaticDecompression to DecompressionMethods.None.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Aug 26 '06 #4
Hi Frederik,

I think I may have found something for you. Check out the articles in the
series below:

http://www.eggheadcafe.com/articles/20011226.asp

There is a compression library referenced in the articles that sounds like
what you need.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Kevin,

I don't seem to be able to solve the decompress problem but I have another
possible solution for my problem.
Maybe you can help me with that.
I should be able to remove the content-encoding field from the header
before the request is send to the server =the server won't compress the
message and I can read the response.
So I think I should create a sort of proxy that checks outgoing messages
for the content-encoding field.

I should capture the messages before they're are being send to port 80,
adjust them and do a resend.

The only problem is that I'm not sure how I can create such a
construction.

Do you have an idea how I can start?
Thx in advance

Frederik
"Kevin Spencer" <uc*@ftc.govschreef in bericht
news:Of**************@TK2MSFTNGP04.phx.gbl...
>You've run into a rather rare animal there, Frederik, although I suppose
that at some point it's likely to catch on popularly, to save bandwidth.

I found a good article on the subject, which also links to some libraries
you can use:

http://www.15seconds.com/issue/020314.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"Frederik Vanderhaegen" <fr*******************@pandora.bewrote in
message news:O5**************@TK2MSFTNGP05.phx.gbl...
>>Hi,

I'm writing an application who 'sniffs' port 80.
The sniffing works 'perfect', I receive a byte array with the data sent
over the port.
My problem is the following, when I write the array to a txt file most
of the content is encoded.
The only things that are readable are the http headers from which I can
read that Internet Explorer uses "content-encoding: gzip, deflate".

So I may conclude that I'll need to decompress the data I received.
This is easier said than done:).
I tried to decompress with GZipStream, DeflateStream (both from .NET
2.0) and SharpZipLib.Gzip.GzipInputstream but neither of them want to
decompress my array.
In the beginning I received several errors about an incorrect
magicnumber and incorrect format. I thought why not add the gzip header
(31,139,8,0,0,0,0,0,0,0) at the start of my array.
.Net didn't throw any exceptions but it didn't decompress (the output is
now an empty file because the bytesread of my decompress stream is 0) my
data either.

Does anyone knows how that Internet Explorer performs the decompression
or how I can perform the decompression myself?

Thx in advance

Frederik.



Aug 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1048
by: Alan G Isaac | last post by:
I have an .zip archive of compressed files that I want to decompress. Using the zipfile module, I tried z=zipfile.ZipFile(local.zip) for zname in z.namelist(): localtxtfile='c:/puthere/'+zname...
2
11375
by: enrio | last post by:
I have a string which I try to decompress: body = zlib.decompress(body) but I get zlib.error: Error -3 while decompressing data: incorrect header check However, I can write the string to...
4
4258
by: Dante | last post by:
Hello, When I try to decompress a response from a web service I'm getting the error: "hexadecimal value 0x1F, is an invalid character. Line 1, position 1." The web server is an apache server....
0
951
by: newbie | last post by:
Hi Can anyone please tell me how I can get and decompress JPEGs from an URL? Thank you!
4
1384
by: umberto | last post by:
Hello, I know that I can process txt files using ASP scrips. But there is a compressed text file (with Winzip) that I want to list on my web page. Is there possibility to decompress it on server...
0
1172
by: JBear | last post by:
Can anyone tell me how to decompress a zip file containing multiple files (but no folder) using a class in the System.IO.Compression namespace? I'm trying to decompress a Google Earth KMZ file,...
1
2535
by: Szeged | last post by:
I'm new to JavaScript. I have relatively large amounts of text (~200 kB) that I need to transfer to my web application every now and then. Using RAR, I get a 5:1 compression ratio on these files,...
2
4923
by: Frederik Vanderhaegen | last post by:
Hi, I'm writing an application who captures everything that passes on port 80. The result op the capture is an byte array with the retrieved values. My problem is the following when i'm trying...
1
4170
by: Carly | last post by:
Hello, I am just wondering if somebody can look on this piece of code and let me know what is wrong with DECOMPRESSION. Dim mystr As String = "flower power" 'deflate Dim mybytearray() As...
0
7052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6744
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6981
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3000
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.